export default defineNuxtRouteMiddleware((to, from) => {
	if (to.path === '/menu') {
		const dolzh = useCookie('dolzh');
		if (dolzh.value === 'Пищеблок') {
			return navigateTo('/menu/menu_pb')
		} else if (dolzh.value === 'Программист') {
			return navigateTo('/menu/menu_prog')
		} else if (dolzh.value === 'Бухгалтер') {
			return navigateTo('/menu/menu_buh')
		}
		return navigateTo(to.path)
	}
	if (to.path === '/login' || from.path === '/login') {
		return;
	} else {
		const username = useCookie('username');
		if (!username.value) {
			return navigateTo('/login');
		}
		const menuStore = useMenuStore();
		const { links } = storeToRefs(menuStore);
		if (links.value.length < 1) {
			return navigateTo('/login')
		}
	}
})